namespace NICWebApi.Extensions.Http.Models;

/// <summary>
/// HTTP上下文信息模型
/// </summary>
public class HttpContextInfo
{
    /// <summary>
    /// 请求ID
    /// </summary>
    public string RequestId { get; set; } = Guid.NewGuid().ToString("N");

    /// <summary>
    /// 请求时间
    /// </summary>
    public DateTime RequestTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 客户端IP地址
    /// </summary>
    public string? ClientIpAddress { get; set; }

    /// <summary>
    /// 客户端IP地址提供者（如X-Forwarded-For等）
    /// </summary>
    public string? IpAddressProvider { get; set; }

    /// <summary>
    /// 主机名
    /// </summary>
    public string? Host { get; set; }

    /// <summary>
    /// 请求路径
    /// </summary>
    public string? Path { get; set; }

    /// <summary>
    /// 请求方法
    /// </summary>
    public string? Method { get; set; }

    /// <summary>
    /// 查询字符串
    /// </summary>
    public string? QueryString { get; set; }

    /// <summary>
    /// 请求体大小（字节）
    /// </summary>
    public long? RequestBodySize { get; set; }

    /// <summary>
    /// 响应体大小（字节）
    /// </summary>
    public long? ResponseBodySize { get; set; }

    /// <summary>
    /// 执行时间（毫秒）
    /// </summary>
    public long ExecutionTime { get; set; }

    /// <summary>
    /// 协议
    /// </summary>
    public string? Protocol { get; set; }

    /// <summary>
    /// 请求的Controller名称
    /// </summary>
    public string? ControllerName { get; set; }

    /// <summary>
    /// 请求的Action名称
    /// </summary>
    public string? ActionName { get; set; }

    /// <summary>
    /// 路由数据
    /// </summary>
    public Dictionary<string, string?> RouteData { get; set; } = new Dictionary<string, string?>();

    /// <summary>
    /// 请求头信息
    /// </summary>
    public Dictionary<string, string?> RequestHeaders { get; set; } = new Dictionary<string, string?>();

    /// <summary>
    /// 用户代理信息
    /// </summary>
    public UserAgentInfo? UserAgent { get; set; }

    /// <summary>
    /// 响应状态码
    /// </summary>
    public int? StatusCode { get; set; }

    /// <summary>
    /// 授权用户ID
    /// </summary>
    public string? UserId { get; set; }

    /// <summary>
    /// 授权用户名
    /// </summary>
    public string? Username { get; set; }

    /// <summary>
    /// 请求来源
    /// </summary>
    public string? Referer { get; set; }

    /// <summary>
    /// Session ID
    /// </summary>
    public string? SessionId { get; set; }

    /// <summary>
    /// 当前中间件管道的数量
    /// </summary>
    public int PipelineCount { get; set; }

    /// <summary>
    /// 错误信息
    /// </summary>
    public string? ErrorMessage { get; set; }

    /// <summary>
    /// 用户角色，逗号分隔
    /// </summary>
    public string? UserRoles { get; set; }
}

/// <summary>
/// 用户代理信息
/// </summary>
public class UserAgentInfo
{
    /// <summary>
    /// 原始用户代理字符串
    /// </summary>
    public string? RawValue { get; set; }

    /// <summary>
    /// 浏览器名称
    /// </summary>
    public string? Browser { get; set; }

    /// <summary>
    /// 浏览器版本
    /// </summary>
    public string? BrowserVersion { get; set; }

    /// <summary>
    /// 操作系统
    /// </summary>
    public string? OperatingSystem { get; set; }

    /// <summary>
    /// 操作系统版本
    /// </summary>
    public string? OperatingSystemVersion { get; set; }

    /// <summary>
    /// 设备类型
    /// </summary>
    public string? DeviceType { get; set; }

    /// <summary>
    /// 是否为移动设备
    /// </summary>
    public bool IsMobile { get; set; }

    /// <summary>
    /// 是否为平板设备
    /// </summary>
    public bool IsTablet { get; set; }

    /// <summary>
    /// 设备品牌
    /// </summary>
    public string? DeviceBrand { get; set; }

    /// <summary>
    /// 设备型号
    /// </summary>
    public string? DeviceModel { get; set; }

    /// <summary>
    /// 是否为爬虫
    /// </summary>
    public bool IsBot { get; set; }

    /// <summary>
    /// 爬虫名称
    /// </summary>
    public string? BotName { get; set; }
}